package com.yanqu.road.entity.activity.guguoxunbao;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_u_activity_guguoxunbao")
public class GuGuoXunBaoUserData extends DataObject {

    @FieldTypeAnnotation(select = true, update = true, desc = "活动id")
    int activityId;

    @FieldTypeAnnotation(select = true, update = true, desc = "玩家id")
    long userId;

    @FieldTypeAnnotation(desc = "总线索数")
    long allClue;

    @FieldTypeAnnotation(desc = "当前探索进度")
    Map<Integer, Integer> curProgress = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "宝物详情")
    Map<Integer, Long> treasureMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "当前位置")
    private int curPlaceId;

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if(this.activityId != activityId) {
            this.activityId = activityId;
            setUpdateOption();
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public long getAllClue() {
        return allClue;
    }

    public void setAllClue(long allClue) {
        if(this.allClue != allClue) {
            this.allClue = allClue;
            setUpdateOption();
        }
    }

    public Map<Integer, Integer> getCurProgress() {
        return curProgress;
    }

    public void setCurProgress(Map<Integer, Integer> curProgress) {
        this.curProgress = curProgress;
        setUpdateOption();
    }

    public void putCurProgress(int key, int val){
        this.curProgress.put(key, val);
        setUpdateOption();
    }

    public Map<Integer, Long> getTreasureMap() {
        return treasureMap;
    }

    public void setTreasureMap(Map<Integer, Long> treasureMap) {
        this.treasureMap = treasureMap;
        setUpdateOption();
    }

    public void addTreasure(int key, long val){
        if(this.treasureMap.containsKey(key)){
            long oldVal = this.treasureMap.get(key);
            this.treasureMap.put(key, oldVal + val);
        }else {
            this.treasureMap.put(key, val);
        }
        setUpdateOption();
    }

    public int getCurPlaceId() {
        return curPlaceId;
    }

    public void setCurPlaceId(int curPlaceId) {
        if(this.curPlaceId != curPlaceId) {
            this.curPlaceId = curPlaceId;
            setUpdateOption();
        }
    }
}
